package com.woniuxy.springboot.contorller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;

/**
 * @author 佘赛飞
 * @create 2021 -10 -07 10:35 AM
 */
//如果当前处理器的方法都是响应JSON,相当于每个方法上都有@ResponseBody
//@RestController
@Controller
public class Mycontroller {
//    @ResponseBody
//    @RequestMapping("/test")
//    public String test(){
//        return "test";
//    }

    @RequestMapping("/my.do")
    public String my(Model model){
        //没有添加thymeleaf模板引擎
        //    直接请求.html页面,进/static
        //    controller转发或者重定向    /static
        //添加thymeleaf模板引擎
        //    直接请求.html页面,进/static
        //    controller,默认转发/templates
        //    controller,显示指定转发或者重定向，模板引擎视图解析器前缀后缀无效，去/static
        //return "/style.css";
//        model.addAttribute("a", "aaa");
//        model.addAttribute("myhtml", "<h1>aaaa</h1>");
//        model.addAttribute("users", Arrays.asList("zs","ls","ww"));
        return "/style.css";
        //return "redirect:/style.css";
    }

    @RequestMapping("/test")
    public String test(Model model) {
        model.addAttribute("a", "aaa");
        model.addAttribute("myhtml", "<h1>aaaa</h1>");
        model.addAttribute("users", Arrays.asList("zs","ls","ww"));
        return "/style.css";
    }
}
